<?php
/**
 * @author all@cosmos-framework.org
 * @copyright (c) 2013 cosmos-framework.org
 * @license http://www.opensource.org/licenses/mit-license.php
 * @link http://cosmos-framework.org/
 * @package cosmos.framework
 * @version 2.0
 */
namespace Cosmos;

abstract class Invoker {

    protected $component;
    protected $componentArgs;
    protected $ref;

    /**
     * @return string class
     */
    public function __a() {

        return $this->component instanceof self ? $this->component->__a() : get_class($this->component);
    }

    /**
     * @param mixed $component
     * @param mixed $componentArgs
     */
    public function __construct($component, $componentArgs, &$ref) {

        $this->component = $component;
        $this->componentArgs = $componentArgs;
        $this->ref = &$ref;
    }

    /**
     * @param string $methodName
     * @param mixed[] $methodArgs
     * @return mixed
     */
    public function __call($methodName, $methodArgs) {

        return call_user_func_array(array($this->component, $methodName), $methodArgs);
    }

}
